Obtaining New York crime data from NYPD Open Data

Data PreProcessing-Removing unnecessary columns

Mapping All the Offenses in New York

Brooklyn Has the Highest Number of Crimes Commited and Staten Island has the least number of crimes commited

Finding the Neighbourhood with the largest number of crimes

Using the Haversine formula to find the distance between two points given the Latitudes and Longitudes

Finding the neighborhood in which the crimes occured

Find the Neighborhood in which there are largest number of crimes

East Harlem has the highest number of Crimes reported(23) and 38 other neighbourhoods has the least number of crimes reported(1)

Cholropleth Map of Crime in Neighborhoods

Finding the desired Neighbourhood having Gym,Grocery Store,Restaurnt,Pharmacy near by. Using Foursquare to get Venues in a Neighbourhood

Defining Function to get near by Venues Using Foursquare API

Replacing Different type of Restaurants to just Restaurants

Now we use the KMeans cluster Algorithm to find the best Neighborhood to live in. For this First we have to determine the value of 'K'. I have used the WSS/Elbow Method and Silhouette Method to determine the best value of K.

At k=3 the above plot has an elbow

At k=3 there is peak in silhouette score

Building the cluster with K=3

The careful examination of all the 3 clusters indicates that the Cluster 1 has neighborhoods with best amenities score and moderate amount of crime rate.

From the above cluster it is clear that Sunnyside is the best neighborhood to live in with having only 2 offences reported in past one year and having a amenities score of 1.7